<template>
	<view class="addhouse">
		<uni-steps class="steps" :options="list1" :active="active" active-color="#026cfd" />
		<view class="selects">
			<view class="item-content">
				<view class="row"><text>小区</text>
					<navigator url="../addHouse/selectCell/selectCell" hover-class="navigator-hover">
						<text v-if="cellName==''">请选择</text>
						<text v-else style="color:#000;">{{JSON.parse(cellName).name}}</text>
						<text>></text>
					</navigator>
				</view>
				<view class="row"><text>楼栋</text>
					<navigator url="../addHouse/selectBuilding/selectBuilding" hover-class="navigator-hover">
						<text v-if="buildingName==''">请选择</text>
						<text v-else style="color:#000;">{{buildingName}}</text>
						<text>></text>
					</navigator>
				</view>
				<view class="row"><text>单元</text>
					<navigator url="../addHouse/selectUnit/selectUnit"  hover-class="navigator-hover">
						<text v-if="unitName==''">请选择</text>
						<text v-else style="color:#000;">{{unitName}}</text>
						<text>></text>
					</navigator>
				</view>
				<view class="row"><text>户号</text>
					<navigator @click="goaccount" hover-class="navigator-hover">
						<text v-if="accountNumber==''">请选择</text>
						<text v-else style="color:#000;">{{accountNumber}}</text>
						<text>></text>
					</navigator>
				</view>
				<view class="row"><text>房屋状态</text>
					<view class="row-tanchu">
						<uni-data-select v-model="value" :localdata="range" @change="change">
						</uni-data-select>
					</view>

				</view>
			</view>
		</view>
		<view  @click="passMsg"  >
			<view class="addhouse">
				下一步
			</view>
		</view>

	</view>

</template>


<script>
	export default {
		components: {},
		data() {
			return {
				active: 0,
				list1: [{
					title: '房屋信息'
				}, {
					title: '住户信息'
				}, {
					title: '物业审核'
				}, {
					title: '认证成功'
				}],
				value: 5,
				range: [{
						value: 0,
						text: "自住"
					},
					{
						value: 1,
						text: "闲置"
					},
					{
						value: 2,
						text: "出租"
					}, {
						value: 3,
						text: "出借"
					}, {
						value: 4,
						text: "其他"
					},
				],
				buildingName: "",
				cellName: "",
				unitName: "",
				accountNumber:"",
				housestatus:"",
			}
		},
		methods: {
			change(e) {
				let   data=this.range[e].text
				uni.setStorage({
					key: "housestatus",
					data: data,
					success: function() {
						console.log("存储成功")
					}
				})
			},
			goaccount(){
				let buildandunit={
					buildingName:this.buildingName,
					unitName:this.unitName
				}
				uni.navigateTo({
					url: '../addHouse/selectAccountNumber/selectAccountNumber?buildandunit='+JSON.stringify(buildandunit)
				});
			},
			// 传参
			passMsg(){
				try {
					const value = uni.getStorageSync("housestatus");
					if (value) {
						this.housestatus = value
					}
				} catch (e) {
					console.log("出错了")
				}
				console.log(this.cellName,"接收的cell")
				let invertcell=JSON.parse(this.cellName)
				let bigdata={
					buildingName:this.buildingName,
					cellName:invertcell,
					unitName:this.unitName,
					housestatus:this.housestatus,
					accountNumber:this.accountNumber
				}
				// let datastr=JSON.stringify(bigdata)
				// console.log(datastr,"datastr")
				uni.navigateTo({
					url: '../../myHouse/addHouse/householdInformation/householdInformation?bigdata='+JSON.stringify(bigdata)
				});
			
			}
		},
		onLoad(option) {
			console.log(option,"option")
			this.buildingName = option.buildingName
			this.cellName = option.cellName
			this.unitName = option.unitName
			this.accountNumber=option.accountNumber
			if (option.buildingName) {
				uni.setStorage({
					key: "buildingName",
					data: option.buildingName,
					success: function() {
						console.log("存储成功")
					}
				})
			} ;
			if (option.cellName) {
				uni.setStorage({
					key: "cellName",
					data: option.cellName,
					success: function() {
						console.log("存储成功")
					}
				})
			} ;
			if (option.unitName) {
				uni.setStorage({
					key: "unitName",
					data: option.unitName,
					success: function() {
						console.log("存储成功")
					}
				})
			};
			if(option.accountNumber){
				uni.setStorage({
					key: "accountNumber",
					data: option.accountNumber,
					success: function() {
						console.log("存储成功")
					}
				})
			}
		},
		onShow() {
			let buildStor
			let cellStor
			let unitStor
			let accStor
			try {
				const value = uni.getStorageSync("buildingName");
				if (value) {
					buildStor = value
				}
			} catch (e) {
				console.log("出错了")
			}
			try {
				const value = uni.getStorageSync("cellName");
				if (value) {
					cellStor = value
				}
			} catch (e) {
				console.log("出错了")
			}
			try {
				const value = uni.getStorageSync("unitName");
				if (value) {
					unitStor = value
				}
			} catch (e) {
				console.log("出错了")
			}
			try {
				const value = uni.getStorageSync("accountNumber");
				if (value) {
					accStor = value
				}
			} catch (e) {
				console.log("出错了")
			}
			// console.log(buildStor,cellStor,unitStor)
			this.buildingName = buildStor
			this.cellName = cellStor
			this.unitName = unitStor
			this.accountNumber=accStor
		}

	}
</script>

<style lang="less" scoped>
	.addhouse {
		.selects {
			padding-left: 38rpx;
			padding-right: 38rpx;
			display: flex;
			flex-direction: column;
			align-items: flex-start;
			border-radius: 10rpx;
			margin-bottom: 42rpx;
			border-top: 1px solid #eee;
			border-bottom: 1px solid #eee;

			.item-content {
				width: 100%;
				display: flex;
				flex-direction: column;
				align-items: flex-start;

				.row {
					display: flex;
					width: 100%;
					justify-content: flex-start;
					padding: 30rpx 0;
					border-bottom: 1px solid #eee;
					align-items: center;

					text:nth-child(1) {
						text-align: left;
						width: 230rpx;
					}

					navigator,
					.row-tanchu {
						flex: 1;
						align-items: center;
						display: flex;
						justify-content: space-between;

						text {
							color: #a8a8a8;
							text-align: left;
						}
					}

					.row-tanchu {
						uni-data-select {
							flex: 1;
						}
					}


				}

				.row-switch {
					padding: 30rpx 0;
					width: 100%;
					display: flex;
					align-items: center;

					text {
						text-align: left;
						width: 230rpx;
					}

					.switch {
						position: relative;
						flex: 1;

						// display: flex;
						// justify-content: flex-end;
						switch {
							position: absolute;
							top: -34rpx;
							right: -24rpx;
						}
					}
				}

				.row:last-child {
					border: 0px;
				}

			}
		}

		.addhouse {
			width: 670rpx;
			height: 82rpx;
			text-align: center;
			line-height: 82rpx;
			background-color: #006fff;
			color: white;
			font-size: 34rpx;
			border-radius: 10rpx;
			position: absolute;
			left: 38rpx;
			bottom: 30rpx;
		}

	}
</style>
<style lang="less">
	.addhouse {
		.uni-steps {
			margin: 60rpx auto;

			.uni-icons {
				font-size: 40rpx !important;
			}
		}

		.uni-select {
			padding: 0px !important;
			border: 0px !important;
		}

		.uni-select__input-placeholder {
			font-size: 30rpx !important;
		}

		.uni-select__input-box {
			height: 30rpx;
		}

		.tab-c {
			height: 200rpx !important;
		}

		.selected-list {
			height: 0px !important;

		}

		.item-text-overflow {
			width: 100% !important;
			text-align: center;
		}
	}
</style>
